<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

 // 实例化人类
    var Human = function(param){
        // 技能
        this.skill = param && param.skill || '保密';
    }
    Human.prototype.getSkill = function() {
        return this.skill;
    }

// 实例化姓名类
    var Named = function(name){
        (function(name, that){
            that.wholdName = name;
            nameList = name.split(/\s+/);
            if( nameList.length === 2){
                that.FirstName = nameList[0];
                that.SecondName = nameList[1];
            }   
        })(name, this)
    }

// 实例化职位类
    var Work = function(workName){
            var workList = {
                'code': ['工程师', '每天沉醉于编程'], 
                'UI' : ['设计师', '设计更似一种艺术'],
                'UE' : ['设计师', '设计更似一种艺术'],
                'teach' : ['教师', '分享也是一种艺术'],
            }
            
            if (workList[workName] ){
                this.wrok = workList[workName][0];
                this.workDescript = workList[workName][1];
            } else {
                this.wrok = workName;
                this.workDescript = '对不起，我们还不清楚你选择职位的相关描述';
            }
    }
    Work.prototype.changeWork = function(work){
        this.work = work;
    }

// 建设者类
    var Person = function(name, work){
        var _person = new Human();
        _person.name = new Named(name);
        _person.work = new Work(work);
        return _person;
    }

    </script>
</body>
</html>